<template>
  <div class="goodDetail">
    <el-form label-width="center">
      <el-row>
        <el-col :xs="{ span: 24 }" :sm="{ span: 12 }" :md="{ span: 12 }" :xl="{ span: 12 }">
          <el-form-item label="商品编码: ">
            {{ goodsDetail.code }}
          </el-form-item>
        </el-col>
        <el-col :xs="{ span: 24 }" :sm="{ span: 12 }" :md="{ span: 12 }" :xl="{ span: 12 }">
          <el-form-item label="商品名称: ">
            {{ goodsDetail.name }}
          </el-form-item>
        </el-col>
        <el-col :xs="{ span: 24 }" :sm="{ span: 12 }" :md="{ span: 12 }" :xl="{ span: 12 }">
          <el-form-item label="商品成本(元): ">
            {{ Number(goodsDetail.buyPrice).toFixed(2) }}
          </el-form-item>
        </el-col>
        <el-col :xs="{ span: 24 }" :sm="{ span: 12 }" :md="{ span: 12 }" :xl="{ span: 12 }">
          <el-form-item label="商品售价(元): ">
            {{ Number(goodsDetail.salePrice).toFixed(2) }}
          </el-form-item>
        </el-col>
        <el-col :xs="{ span: 24 }" :sm="{ span: 12 }" :md="{ span: 12 }" :xl="{ span: 12 }">
          <el-form-item label="生产地: ">
            {{ goodsDetail.productAddr }}
          </el-form-item>
        </el-col>
        <el-col :xs="{ span: 24 }" :sm="{ span: 12 }" :md="{ span: 12 }" :xl="{ span: 12 }">
          <el-form-item label="发货地: ">
            {{ goodsDetail.shipAddr }}
          </el-form-item>
        </el-col>
        <el-col :xs="{ span: 24 }" :sm="{ span: 12 }" :md="{ span: 12 }" :xl="{ span: 12 }">
          <el-form-item label="商品型号: ">
            {{ goodsDetail.model }}
          </el-form-item>
        </el-col>
        <el-col :xs="{ span: 24 }" :sm="{ span: 12 }" :md="{ span: 12 }" :xl="{ span: 12 }">
          <el-form-item label="库存量: ">
            {{ goodsDetail.stock }}
          </el-form-item>
        </el-col>
        <el-col :xs="{ span: 24 }" :sm="{ span: 12 }" :md="{ span: 12 }" :xl="{ span: 12 }">
          <el-form-item label="创建时间:">
            {{ goodsDetail.createTime }}
          </el-form-item>
        </el-col>
        <el-col :xs="{ span: 24 }" :sm="{ span: 12 }" :md="{ span: 12 }" :xl="{ span: 12 }">
          <el-form-item label="商品来源: ">
            {{ goodsDetail.source }}
          </el-form-item>
        </el-col>
        <el-col :xs="{ span: 24 }" :sm="{ span: 12 }" :md="{ span: 12 }" :xl="{ span: 12 }">
          <el-form-item label="商品介绍: ">
            {{ goodsDetail.introduce }}
          </el-form-item>
        </el-col>
        <el-col :xs="{ span: 24 }" :sm="{ span: 12 }" :md="{ span: 12 }" :xl="{ span: 12 }">
          <el-form-item label="商品存放地: ">
            {{ goodsDetail.location }}
          </el-form-item>
        </el-col>
        <el-col :xs="{ span: 24 }" :sm="{ span: 16 }" :md="{ span: 16 }" :xl="{ span: 16 }">
          <div v-for="item in goodsDetail.photoList" :key="item.id">
            <img :src="item.photoName" alt="">
          </div>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>

<script>
import { getGoodInfoByCode } from '@a/business/goods.js'
export default {
  data() {
    return {
      routePath: '',
      goodsDetail: {}
    }
  },
  mounted() {
    this.routePath = this.$route.params.id
    this.getList()
  },
  methods: {
    getList() {
      const routePath = this.routePath
      getGoodInfoByCode(routePath).then(res => {
        console.log(res)
        if (res.code === 0) {
          this.goodsDetail = res.data
        } else {
          this.$message({
            type: 'error',
            message: res.msg
          })
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.goodDetail {
  padding: 100px 300px 0;
}
.imgBox {
  margin-top: 30px;
}
img {
  width: 100%;
  height: auto;
}
</style>
